package com.cloud.drore.eboss.supplier.mapper.provider;

import com.cloud.drore.eboss.supplier.entity.ProductConsumeRelation;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/2/2 16:07 <br>
 * @Author: <a href="575842778@qq.com">郑永涛</a>
 */
public class ProductConsumeRelationProvider {

    public ProductConsumeRelationProvider(){

    }

    public String selectRelationByParam(ProductConsumeRelation consumeRelation){
        String sql = "select id,product_id,consume_id,poi_id,merchant_id from eboos_product_consume_relation " +
                " where is_deleted = 0 ";
        if(consumeRelation.getConsumeId() != null)
            sql += " and consume_id =" + consumeRelation.getConsumeId() + "";
        if(consumeRelation.getProduct_id() != null)
            sql += " and product_id ='" + consumeRelation.getProduct_id() + "'";
        if(consumeRelation.getPoiId() != null)
            sql += " and poi_id ='" + consumeRelation.getPoiId() + "'";
        if(consumeRelation.getMerchantId() != null)
            sql += " and merchant_id =" + consumeRelation.getMerchantId() + "";
        return sql;
    }

    public String updateProductConsumeRelationByParam(ProductConsumeRelation consumeRelation){
        int count = 0;
        String sql = " update eboos_product_consume_relation set ";
        if (consumeRelation.getConsumeId()!=null) {
            sql += " consume_id=" + consumeRelation.getConsumeId() + "";
            count++;
        }
        sql += " ,poi_id =" + consumeRelation.getPoiId() + "";
        sql += " where product_id='" + consumeRelation.getProduct_id() + "'";
        return sql;
    }
}